#ifndef OBJECT_H
#define OBJECT_H

#include <vector>
#include <queue>
#include "point_operator.h"
#include <iostream>
using namespace std;

typedef float Point;

struct triangle{
	bool alive;
	int index;
	int pt[3];	
	int version_to_tri[3];	// stores adj triangle indexes according to abc, bca & cab
	vector<int> child_tri;
};
struct pt_vertex{
	int index;
	Point xyz[3];
};

class object{

private:
	point_operator op;
	vector<pt_vertex> vtx_vector;
	vector<triangle> tri_vector;

public:
	object();
	vector<triangle>  GetTriangleVector();
	vector<pt_vertex> GetVertexVector();

	void		AddTriangle(int vertex[3], int version_to_tri[3]);
	void		AddTriangle(triangle);
	void		AddChildTriangle(int, int);
	triangle	GetTriangleWithIndex(int);
	void		SetTriangleAsDeadWithIndex(int);
	void		SetTriangleIndexVersionValueAsPointer(int tri_index, int version_num, int *p);
	int			GetTriangleSize();
	bool		TriangleIndexHasVertexIndex(int, int);
	bool		TriangleIndexHasChildIndex(int, int);
	vector<triangle>::iterator GetTriangleVectorPointer();

	int			AddVertex(Point*);
	int			AddVertexWithoutConstraint(Point *);
	int			GetVertexSize();
	void		GetVertexPtArrayWithIndex(int, Point[3]);
	void		GetAllVertexPtArrayWithTriangleIndex(int, Point[][3]);
	int			GetVertexIndexWithPtArray(Point*);
	void		SetTriangleIndexVersionValue(int,int,int);

	void		UpdateTriangleVersionToTri(int tri_index, int version_index, int adj_tri_index);
	int			GetEdgeOfTriangle(triangle, int, int);
	int			GetEdgeOfTriangleThatHasVertexIndexAsStartingPointOfEdge(triangle, int);
	int			FindChildTriThatHasPointInEdge(triangle parent_tri, float p[3], int &child_edge_type);
};

#endif